﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageRoutines.aspx.cs" Inherits="FatFreeFitness._secured.management.ManageRoutines" masterpagefile="../../_layout/_master/AdminMaster.master" %>
<asp:Content id="Content1" runat="Server" contentplaceholderid="AdminContent">
    <div>
    
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" 
            DataSourceID="EntityDsRoutines" DefaultMode="Insert" 
            oniteminserted="FormView1_ItemInserted" Width="567px">
            <InsertItemTemplate>
                <br />
                Name:
                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
                <br />
                <br />
                Description:
                <asp:TextBox ID="DescriptionTextBox" runat="server" 
                    Text='<%# Bind("Description") %>' />
                <br />
                <br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" />
&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" 
                    CommandName="Cancel" Text="Cancel" />
            </InsertItemTemplate>
        </asp:FormView>
        <br />
    
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" 
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" 
            AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0" 
            DataSourceID="EntityDsRoutines" GridLines="None" 
            AutoGenerateColumns="False">
<MasterTableView AllowAutomaticDeletes="False" AllowAutomaticInserts="False" 
                AllowAutomaticUpdates="False" DataKeyNames="ID" 
                DataSourceID="EntityDsRoutines">
    <NestedViewTemplate>
        <asp:EntityDataSource ID="EntityDsUnselectedSteps" runat="server" 
            ConnectionString="name=FatFreeFitnessEntities" 
            DefaultContainerName="FatFreeFitnessEntities" EnableFlattening="False" 
            EntitySetName="TemplateSteps" Select="it.[ID], it.[Name], it.[Description]" 
            
            Where="NOT EXISTS(SELECT VALUE r FROM it.TemplateRoutineSteps AS r WHERE r.RoutineID = @RoutineID)" 
            EntityTypeFilter="">
            <WhereParameters>
                <asp:ControlParameter ControlID="hidResourceID" Name="RoutineID" 
                    PropertyName="Value" Type="Int32" />
            </WhereParameters>
        </asp:EntityDataSource>
        <asp:HiddenField ID="hidResourceID" runat="server" Value='<%# Eval("ID") %>' />
        <asp:EntityDataSource ID="EntityDsRoutineSteps" runat="server" 
            AutoGenerateWhereClause="True" ConnectionString="name=FatFreeFitnessEntities" 
            DefaultContainerName="FatFreeFitnessEntities" EnableDelete="True" 
            EnableFlattening="False" EnableInsert="True" 
            EntitySetName="TemplateRoutineSteps" Where="" Include="TemplateStep">
            <WhereParameters>
                <asp:ControlParameter ControlID="hidResourceID" Name="RoutineID" 
                    PropertyName="Value" Type="Int32" />
            </WhereParameters>
        </asp:EntityDataSource>
        <!--
            DataSource='<%# Container.FindControl("EntityDsRoutineSteps") %>' 

        -->
        <asp:FormView ID="FormView2" runat="server" DataKeyNames="RoutineStepID" 
            DefaultMode="Insert" Width="390px" oniteminserted="FormView2_ItemInserted" 
            oniteminserting="FormView2_ItemInserting" 
            onmodechanging="FormView2_ModeChanging" 
            DataSourceID="EntityDsRoutineSteps" >
            <InsertItemTemplate>
                Step:
                <asp:DropDownList ID="DropDownList1" runat="server" 
                    DataSourceID="EntityDsUnselectedSteps" DataTextField="Name" DataValueField="ID" 
                    SelectedValue='<%# Bind("StepID") %>'>
                </asp:DropDownList>
                <br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" />
&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" 
                    CommandName="Cancel" Text="Cancel" />
            </InsertItemTemplate>
        </asp:FormView>
        <telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="False" 
            AutoGenerateDeleteColumn="True" CellSpacing="0" GridLines="None" 
            AllowAutomaticDeletes="True" onitemdeleted="RadGrid2_ItemDeleted">
            <MasterTableView DataSourceID="EntityDsRoutineSteps" DataKeyNames="RoutineStepID">
                <CommandItemSettings ExportToPdfText="Export to PDF" />
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" 
                    Visible="True">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" 
                    Visible="True">
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="RoutineStepID" DataType="System.Int32" 
                        FilterControlAltText="Filter RoutineStepID column" HeaderText="RoutineStepID" 
                        ReadOnly="True" SortExpression="RoutineStepID" UniqueName="RoutineStepID" 
                        Visible="False">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" 
                        HeaderText="Step" UniqueName="TemplateColumn">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("TemplateStep.Name") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
                <WebServiceSettings>
                    <ODataSettings InitialContainerName="">
                    </ODataSettings>
                </WebServiceSettings>
            </FilterMenu>
            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                <WebServiceSettings>
                    <ODataSettings InitialContainerName="">
                    </ODataSettings>
                </WebServiceSettings>
            </HeaderContextMenu>
        </telerik:RadGrid>
    </NestedViewTemplate>
<CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="New" ShowAddNewRecordButton="true"></CommandItemSettings>

<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

    <Columns>
        <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" 
            FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" 
            SortExpression="ID" UniqueName="ID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Name" 
            FilterControlAltText="Filter Name column" HeaderText="Name" 
            SortExpression="Name" UniqueName="Name">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Description" 
            FilterControlAltText="Filter Description column" HeaderText="Description" 
            SortExpression="Description" UniqueName="Description">
        </telerik:GridBoundColumn>
        <telerik:GridButtonColumn CommandName="Select" 
            FilterControlAltText="Filter column column" Text="Select" UniqueName="column">
        </telerik:GridButtonColumn>
    </Columns>

<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    <FormTemplate>
    </FormTemplate>
</EditFormSettings>
</MasterTableView>

<FilterMenu EnableImageSprites="False">
<WebServiceSettings>
<ODataSettings InitialContainerName=""></ODataSettings>
</WebServiceSettings>
</FilterMenu>

<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
<WebServiceSettings>
<ODataSettings InitialContainerName=""></ODataSettings>
</WebServiceSettings>
</HeaderContextMenu>
        </telerik:RadGrid>
    
        <br />
        <br />
    
    </div>
    <asp:EntityDataSource ID="EntityDsRoutines" runat="server" 
        ConnectionString="name=FatFreeFitnessEntities" 
        DefaultContainerName="FatFreeFitnessEntities" EnableDelete="True" 
        EnableFlattening="False" EnableInsert="True" EnableUpdate="True" 
        EntitySetName="TemplateRoutines">
    </asp:EntityDataSource>
    </asp:Content>
